<?php
/**
 * @package		简易CMS
 * @subpackage	后台首页
 * @version		$Id: admincp_index.php 8 2012-06-07 12:37:35Z htmambo@gmail.com $
 * @author		Hoping
 * @copyright	Copyright (C) 2010 Hoping Software Studio.
 */

if(!defined('IN_JYCMS') || !defined('IN_ADMINCP')) {
	exit('Access Denied');
}
/*
if(@file_exists(ROOT_PATH.'./install/index.php')) {
	@unlink(ROOT_PATH.'./install/index.php');
	if(@file_exists(ROOT_PATH.'./install/index.php')) {
		dexit('Please delete install/index.php via FTP!');
	}
}
*/
@include_once ROOT_PATH.'./source/version.php';

$serverinfo = PHP_OS.' / PHP v'.PHP_VERSION;
$serverinfo .= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
$serversoft = $_SERVER['SERVER_SOFTWARE'];
$dbversion = DB::result_first("SELECT VERSION()");

if(@ini_get('file_uploads')) {
	$fileupload = ini_get('upload_max_filesize');
} else {
	$fileupload = '<font color="red">'.$lang['no'].'</font>';
}


$dbsize = 0;
$query = DB::query("SHOW TABLE STATUS LIKE '{$_G['config']['db'][1]['tablepre']}%'", 'SILENT');
while($table = DB::fetch($query)) {
	$dbsize += $table['Data_length'] + $table['Index_length'];
}
$dbsize = $dbsize ? sizecount($dbsize) : $lang['unknown'];

if(isset($_G['gp_attachsize'])) {
	$attachsize = DB::result_first("SELECT SUM(filesize) FROM #__common_attachment");
	$attachsize = is_numeric($attachsize) ? sizecount($attachsize) : $lang['unknown'];
} else {
	$attachsize = '<a href="'.ADMINSCRIPT.'?action=index&attachsize">[ '.$lang['detail'].' ]</a>';
}

$articlesmod = DB::result_first("SELECT COUNT(*) FROM #__portal_article_title WHERE status='1'");
$articlecommentsmod = DB::result_first("SELECT COUNT(*) FROM #__common_comment WHERE status='1'");

cpheader();
shownav();

showsubmenu('home_welcome', array(), '', array('sitename' => $_G['setting']['sitename']));

$onlines = '';
$query = DB::query("SELECT cps.uid,cps.dateline,m.username FROM #__common_admincp_session cps
	LEFT JOIN #__common_member m ON m.uid=cps.uid WHERE panel='1'
	ORDER BY cps.dateline DESC");
while($online = DB::fetch($query)) {
	$onlines .= '<a href="index.php?option=member&task=profile&uid='.$online['uid'].'" title="'.dgmdate($online['dateline']).'">'.$online['username'].'</a>&nbsp;&nbsp;&nbsp;';
}

if($articlesmod || $articlecommentsmod || !empty($verify)) {
	showtableheader('', 'nobottom fixpadding');
	showtablerow('', '', '<h3 class="left margintop">'.cplang('home_mods').': </h3><p class="left difflink">'.
		($articlesmod ? '<a href="'.ADMINSCRIPT.'?action=moderate&operation=articles&dateline=all">'.cplang('home_mod_articles').'</a>(<em class="lightnum">'.$articlesmod.'</em>)' : '').
		($articlecommentsmod ? '<a href="'.ADMINSCRIPT.'?action=moderate&operation=articlecomments&dateline=all">'.cplang('home_mod_articlecomments').'</a>(<em class="lightnum">'.$articlecommentsmod.'</em>)' : '').
		$verify.
		'</p><div class="clear"></div>'
	);
	showtablefooter();
}

showtableheader('home_onlines', 'nobottom fixpadding');
echo '<tr><td>'.$onlines.'</td></tr>';
showtablefooter();

showtableheader('home_sys_info', 'fixpadding');
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
	cplang('home_version'),
	'JYCMS '.JYCMS_VERSION.' Release '.JYCMS_RELEASE));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
	cplang('home_environment'),
	$serverinfo
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
	cplang('home_serversoftware'),
	$serversoft
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
	cplang('home_database'),
	$dbversion
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
	cplang('home_upload_perm'),
	$fileupload
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
	cplang('home_database_size'),
	$dbsize
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
	cplang('home_attach_size'),
	$attachsize
));
showtablefooter();


echo '</div>';
